package com.xu.commons.dao;

import java.util.List;

import javax.sql.DataSource;

import com.xu.commons.dao.mpl.DefaultDataSourceFactory;

public class DatabaseHelper {
	private static final DataSourceFactory dataSourceFactory=new DefaultDataSourceFactory();
	
	private static final DefaultDataAccessor defaultDataAccessor=new DefaultDataAccessor();
	
	public static DataSource  getDataSource(){
		return dataSourceFactory.getDataSource();
	}
	/**
     * 根据 SQL 语句查询 Entity
     */
	 public  static <T> T queryEntity(Class<T> entityClass,String sql,Object ...params){
		 return defaultDataAccessor.queryEntity(entityClass, sql, params);
	 }
	 public static <T> List<T> queryEntityList(Class<T> entityClass,String sql,Object ...params){
		 return defaultDataAccessor.queryEntityList(entityClass, sql, params);
	 }
}
